﻿
Imports std

Public Class elpmis_base_storing_type(Of T)
    Inherits hashmap(Of String, T, _63, _string_to_uint32)
End Class

Public Class variables_t(Of T As bare_variable)
    Inherits elpmis_base_storing_type(Of T)
End Class

Public Class variables_t
    Inherits variables_t(Of bare_variable)
End Class

Public Class const_variables_t
    Inherits variables_t(Of const_bare_variable)
End Class

Public Class functions_t
    Inherits elpmis_base_storing_type(Of [function])
End Class

Public Class parameters_t
    Inherits vector(Of pair(Of String, bare_variable))
    Implements iParameters, iParametersWithMapping

    'a helper function to add a const_bare_variable to the parameters_t
    Public Overloads Function insert(ByVal name As String, _
                                     ByVal type As typeDefination, ByVal value As Object) As Boolean
        Return push_back(make_pair(name, _
                                   convertor.cast(Of bare_variable) _
                                                 (New const_bare_variable(type, value))))
    End Function

    Public Function invoke(ByVal ctx As context) As Boolean Implements iParameters.invoke
        Dim i As Int64
        For i = 0 To size() - 1
            ctx.insertVariable(Me(i).first, Me(i).second)
        Next

        Return True
    End Function

    Private Function __size(ByVal obj As Object) As Int64
        Return size()
    End Function

    Private Function _at(ByVal i As Int64, ByRef v As bare_variable, ByVal obj As Object) As Int64
        v = at(i).second
        Return True
    End Function

    Public Function invoke(ByVal ctx As context, _
                           ByVal m As iParametersMapping) As Boolean Implements iParametersWithMapping.invoke
        If m Is Nothing Then
            Return invoke(ctx)
        Else
            Return invokemapping(ctx, AddressOf __size, AddressOf _at, m, Nothing)
        End If
    End Function
End Class
